Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

queueobj

Package Overview
Dependencies
Maintainers
1
Versions
103
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

queueobj

Queue Objects For Processing

  • 10.5.5
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
10
increased by25%
Maintainers
1
Weekly downloads
 
Created
Source

Queue javascript objects dynamically then process the queue according to the appender.

Included tag appenders:

  • all - synchronous - process all added objects.
  • func_all - synchronous - process custom functions to added objects.
  • top_one - synchronous - process only the object in the 0(zero) position of the process array.
  • bottom_one - synchronous - process only the object in the last position of the process array.
  • sync_all - synchronous - All appenders are synchronous now. Sync_all is no different than all .
  • status - synchronous - queue and process all objects by status.
  • version - synchronous - queue and process all objects by version.

Installation

NPM

Mocha Test

npm test

General Setup Test

npm run test_all
npm run test_top_one
npm run test_bottom_one
npm run test_func_all
npm run test_sync_all
npm run test_status
npm run test_version

Usage


var colors = require('colors')
var queue = require("queueobj");

class test1 {
    constructor() {
        this.id = 100
        this.process = this.process.bind(this)
    }

    process(callback) {
        setTimeout(() => {
            console.log(`processing test1`.cyan)
            console.log(`some async process`)
            callback({success: {msg: `processing all (${this.id})`}})
        }, 3000)
    }
}

class test2 {
    constructor() {
        this.id = 200
        this.process = this.process.bind(this)
    }

    process(callback) {
        let msg = `some kinda problem here in id(${this.id})`
        // callback({error: {msg: msg}})  //this will show errors
        callback({success: {msg: `processing all (${this.id})}`}})   //this will show no errors
    }

    ping() {
        console.log('hello from test2'.rainbow)
    }
}

class test3 {
    constructor() {
        this.id = 300
        this.process = this.process.bind(this)
    }

    process(callback) {
        callback({success: {msg: `processing all (${this.id})}`}})   
    }
}

class test4 {
    constructor() {
        let t = this
        t.id = 400
        t.custom_function = t.custom_function.bind(this)
    }

    custom_function(callback) {
        let msg = `custom func problem here id(${this.id})`
        setTimeout(() => {
            // callback({error: {msg: msg}})  //this will show errors
            callback({success: {msg: `processing all (${this.id})}`}})   //this will show no errors
        }, 3000)
    }
}
let tst4 = new test4()
let qObj = new queue(), props = { appender: 'sync_all' }

qObj.load(props).add(new test1()).add(new test2()).add(new test3()).add(tst4.custom_function)

qObj.process().then(res => {
    console.log(`success with all sync processing: (${JSON.stringify(res)})`.bold.italic.green)
}, err => {
    console.log(`errors with all sync processing: (${JSON.stringify(err)})`.red)
})

Keywords

FAQs

Package last updated on 16 Jan 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc